package Operation;

import Book.Library;

import java.util.Scanner;

public class FindBook implements IOperation{
    @Override
    public void work(Library library) {
        if(library.getSize() == 0){
            System.out.println("书架为空");
            return;
        }
        System.out.println("查找图书");
        System.out.println("请输入书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        for (int i = 0; i < library.getSize(); i++) {
            if(library.getBook(i).getName().equals(name)){
                System.out.println("找到了 《" + name + "》 序号为：" + (i+1));
                return;
            }else {
                System.out.println("未找到找到了 《" + name + "》" );
                return;
            }
        }
    }
}
